package com.zzl.bonds.ticket.constant;

/**
 * 审批流程状态 审批状态 1 审批中， 2 审核未通过 3 审核通过
 *
 * @author szsw
 * @date 2021/12/2 15:27:08
 */
@SuppressWarnings("unused")
public enum ApproveProcessEnum {

    /**
     *
     */
    APPROVE_PROCESS_ING("1", "审批中", StyleEnum.STYLE_BLUE),
    APPROVE_PROCESS_FAIL("2", "审核未通过", StyleEnum.STYLE_RED),
    APPROVE_PROCESS_SUCESS("3", " 审核通过", StyleEnum.STYLE_GREEN),
    APPROVE_PROCESS_CANCEL("4", " 审核撤回", StyleEnum.STYLE_GRAY),
    ;

    private String code;
    private String name;
    private StyleEnum styleEnum;

    ApproveProcessEnum(String code, String name, StyleEnum styleEnum) {
        this.code = code;
        this.name = name;
        this.styleEnum = styleEnum;
    }

    /**
     * 通过 code 获取 name
     *
     * @param code code
     * @return name
     */
    public static String getNameByCode(String code) {
        ApproveProcessEnum anEnum = getEnum(code);
        if(anEnum != null){
            return anEnum.name;
        }
        return "";
    }

    /**
     * 通过 code 获取 枚举对象
     *
     * @param code code
     * @return 枚举对象
     */
    public static ApproveProcessEnum getEnum(String code) {
        for (ApproveProcessEnum statusEnum : ApproveProcessEnum.values()) {
            if (statusEnum.code.equals(code)) {
                return statusEnum;
            }
        }
        return null;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public StyleEnum getStyleEnum() {
        return styleEnum;
    }
}
